package com.tang;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import tang.ProducerApplication;
import tang.rabbitmq.config.RabbitMQconfig;

@ContextConfiguration(classes = ProducerApplication.class)
@SpringBootTest
@RunWith(SpringRunner.class)
public class ProducerText {
  //1 .注入RabbitTemplate 发送消息
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Test
    public void textSend(){
      //发送消息 第二个参数是Topic通配符模式
        rabbitTemplate.convertAndSend(RabbitMQconfig.EXCHANGE_NAME,"boot.hha","hello,boot");
    }
}
